﻿@{
	ViewData["Title"] = "AddMaterialView";
	Layout = null;
}
<link href="~/libs/layui-v2.9.21/layui-v2.9.21/layui/css/layui.css" rel="stylesheet" />

<form class="layui-form" action="">
	<div class="layui-form-item">
		<div class="layui-inline">
			<label class="layui-form-label">物料编码</label>
			<div class="layui-input-inline layui-input-wrap">
				<input type="text" name="materialCode" lay-verify="required" placeholder="请输入物料编码" class="layui-input">
			</div>
			<div class="layui-form-mid" style="padding: 0!important;">
				<input type="checkbox" lay-skin="switch" lay-filter="switchTest">
			</div>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">物料名称</label>
		<div class="layui-input-block">
			<input type="text" name="materialName" lay-verify="required" placeholder="请输入物料名称" class="layui-input">
		</div>
	</div>
	<div class="layui-form-item layui-form-text">
		<label class="layui-form-label">规格型号</label>
		<div class="layui-input-block">
			<textarea placeholder="请输入规格型号" name="specificationsModels" class="layui-textarea"></textarea>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">单位</label>
		<div class="layui-input-block">
			<select name="unit">
				<option value=""></option>
				<option value="吨">吨</option>
				<option value="个">个</option>
				<option value="公斤">公斤</option>
				<option value="分米">分米</option>
				<option value="米">米</option>
			</select>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">物料/产品分类</label>
		<div class="layui-input-block">
			<select name="materialType" id="ID-tree-demo">
				<option value=""></option>
			</select>
		</div>
	</div>


	<div class="layui-form-item">
		<label class="layui-form-label">是否启用</label>
		<div class="layui-input-block">
			<input type="radio" name="state" value="是" title="是" checked>
			<input type="radio" name="state" value="否" title="否">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">安全库存</label>
		<div class="layui-input-block">
			<input type="radio" name="safetyStock" value="是" title="是" checked>
			<input type="radio" name="safetyStock" value="否" title="否">
		</div>
	</div>
	<div class="layui-form-item">
		<div class="layui-input-block">
			<button type="submit" class="layui-btn" lay-submit lay-filter="demo1">立即提交</button>
			<button type="reset" class="layui-btn layui-btn-primary">重置</button>
		</div>
	</div>
</form>

<script src="~/libs/jquery/jquery.js"></script>
<script src="~/libs/layui-v2.9.21/layui-v2.9.21/layui/layui.js"></script>

<script>
		layui.use(['form', 'laydate', 'util'], function(){
		  var form = layui.form;
		  var layer = layui.layer;
		  var laydate = layui.laydate;
		  var util = layui.util;

		  // 提交事件
		  form.on('submit(demo1)', function(data){
			var field = data.field; // 获取表单字段值
			// 显示填写结果，仅作演示用
			layer.alert(JSON.stringify(field), {
			  title: '当前填写的字段值'
			});
			// 此处可执行 Ajax 等操作
			// …
			return false; // 阻止默认 form 跳转
		  });
		});

	layui.use(['table','layer','form','tree'],function(){
		var tree = layui.tree;
		var layer = layui.layer;
		var util = layui.util;
		var form=layui.form;
		var table=layui.table;
		searchmaterial();

		//初始化绑定树形
		inittrees()

		function inittrees(){
			$.ajax({
				url:'/Puffs/GetMatertypeTrees',
				data:{orderby:0},
				type:'get',
				success:function(res){
					console.log(res.data)
					tree.render({
						elem: '#ID-tree-demo',
						data:res.data,
						showLine: false,  // 是否开启连接线
						accordion:true,
						click: function(obj){

					   }
					});
				}
			})
		}
		});
</script>